/* eslint-disable semi */
/* eslint-disable semi */
/* eslint-disable quotes */
<template>
    <van-pull-refresh v-model="isLoading">
        <div class="TopList">
            <router-link to="/HamPeople">
                <van-icon class="Backlink"
                          name="arrow-left" />
            </router-link>

            <div class="TopList-span">
                <span> 火腿师申请 </span>

            </div>

        </div>

        <div class="shadow"> </div>
        <div class="banner"
             ref="scroll">
            <!-- 轮播图 -->
            <div id="topBanner"
                 class="hello-1">
                <van-cell-group class="cell-Group">
                    <van-field v-model="compellation"
                               class="cell-List"
                               required
                               label="您的姓名"
                               placeholder="请输入真实姓名" />
                    <van-field v-model="phone"
                               type="tel"
                               class="cell-List"
                               required
                               label="手机号码"
                               placeholder="请输入手机号码" />
                    <van-field v-model="unitaddress "
                               class="cell-List"
                               required
                               label="工作单位"
                               placeholder="请输入您的单位名称" />
                    <van-field v-model="familyaddress"
                               class="cell-List"
                               required
                               label="您的地址"
                               placeholder="请输入您的地址" />

                    <van-field v-model="message1"
                               class="cell-List-2"
                               required
                               rows="2"
                               autosize
                               label="自我介绍"
                               type="textarea"
                               maxlength="200"
                               right-icon="question-o"
                               placeholder="请简单自我介绍下..."
                               show-word-limit
                               @click-right-icon="showNumber()" />

                    <van-field class="cell-List"
                               required
                               rows="5"
                               autosize
                               label="上传照片"
                               value="请上传您的头像照片，最多一张"
                               disabled />

                    <van-uploader class="updateImg"
                                  :after-read="afterRead" />

                </van-cell-group>

            </div>

            <!-- 中间秒杀图片 -->

            <div class="lastadd"
                 @click="submitdata()"> 确定提交</div>

        </div>
    </van-pull-refresh>
</template>

<script>
import TabBar from "./TabBar.vue";

//引入其他子组件
export default {
    components: {
        TabBar
    },
    // eslint-disable-next-line space-before-function-paren
    data() {
        return {
            count: 0,
            isLoading: false,
            index: 0,
            message1: "",
            compellation: "",
            phone: "",
            unitaddress: "",
            familyaddress: "",
            compellationarr: ["王纪林", "宋元孝", "李浩凡"],
            phonearr: ["18515069755", "18206797737", "18697375820"],
            unitaddressarr: ["云南省-昆明市-盘龙区", "昆明", "恒隆广场"],
            familyaddressarr: ["河南省-新乡市-汲县", "昆明", "恒隆广场"],

            bannerimages: [
                { id: 0, imgSrc: require("../assets/images/a16.jpg") }
                // { id: 1, imgSrc: require("../assets/images/a18.jpg") }
            ],
            middleimages: [{ id: 0, imgSrc: require("../assets/images/none.png") }]
        };
    },

    mounted() {
        // 上拉加载
    },
    // eslint-disable-next-line space-before-function-paren
    // created:vue生命周期中的钩子函数，在这个时间点，data中的数据已经注入到响应式系统中
    created() { },

    methods: {
        afterRead(file) {
            // 此时可以自行将文件上传至服务器
            console.log(file);
        },
        //弹出提示
        showNumber() {
            this.$toast({
                message: "字数不能超过200个"
            });
        },

        //提交信息验证
        submitdata() {
            let compellation = this.compellation;
            let phone = this.phone;
            let unitaddress = this.unitaddress;
            let familyaddress = this.familyaddress;
            let message1 = this.message1;

            //姓名验证
            if (!compellation) {
                this.$toast({
                    message: "请输入真实姓名！"
                });
            } else if (!phone) {
                this.$toast({
                    message: "请输入手机号码！"
                });
            } else if (!unitaddress) {
                this.$toast({
                    message: "请输入单位地址！"
                });
            } else if (!familyaddress) {
                this.$toast({
                    message: "请输入家庭住址！"
                });
            } else if (!message1) {
                this.$toast({
                    message: "请输入自我介绍！"
                });
            } else if (!/^[\u0391-\uFFE5A-Za-z]+$/.test(compellation)) {
                this.$toast({
                    message: "请输入正确真实姓名！"
                });
            } else if (!/^[1][3-9][0-9]{9}$/.test(phone)) {
                this.$toast({
                    message: "请输入正确手机号！"
                });
            } else if (
                !/^([\u4e00-\u9fa5]+(省|自治区)-)?[\u4e00-\u9fa5]+市-[\u4e00-\u9fa5]+(区|县)$/.test(
                    unitaddress
                )
            ) {
                this.$toast({
                    message: "请输入正确单位名称！"
                });
            } else if (
                !/^([\u4e00-\u9fa5]+(省|自治区)-)?[\u4e00-\u9fa5]+市-[\u4e00-\u9fa5]+(区|县)$/.test(
                    familyaddress
                )
            ) {
                this.$toast({
                    message: "请输入正确家庭住址！"
                });
            } else if (!/^[\u0391-\uFFE5A-Za-z]+$/.test(message1)) {
                this.$toast({
                    message: "自我介绍格式错误！"
                });
            } else {
                for (var i = 0; i < this.compellationarr.length; i++) {
                    if (
                        compellation == this.compellationarr[i] &&
                        phone == this.phonearr[i] &&
                        unitaddress == this.unitaddressarr[i] &&
                        familyaddress == this.familyaddressarr[i]
                    ) {
                        this.$toast({
                            message: "输入成功！"
                        });
                    }

                    // if (compellation == this.compellationarr[i]) {
                    //   if (phone == this.phonearr[i]) {
                    //     if (unitaddress == this.unitaddressarr[i]) {
                    //       if (familyaddress == this.familyaddressarr[i]) {
                    //         this.$toast({
                    //           message: "输入成功！"
                    //         });
                    //       }
                    //     }
                    //   }
                    // }
                }
            }
        }
    }
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
/* //自定义.css的样式路径 */
/* @import "../css/HomePage.css"; */

* {
    padding: 0;
    margin: 0;
}
body {
    background-color: #f6f6f6;
    position: fixed;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    margin: 0;
    display: block;
}
div {
    display: block;
    box-sizing: border-box;
}
.shadow {
    height: 9px;
    width: 100%;
    background: #f6f6f6;
}

.TopList {
    display: flex;
    width: 100%;
    height: 50px;
    font-size: 20px;
    text-align: left;
    background: #ffffff;
    line-height: 50px;
}
.Backlink {
    margin-top: 15px;
    margin-left: 15px;
    color: #888;
}
.TopList-span {
    display: flex;
    height: 20px;
    margin-top: 0px;
    margin-left: 110px;
    font-size: 16px;
    width: 60%;
}

.banner {
    width: 100%;
    height: 100%;
}
.hello-1 {
    width: 100%;
    height: auto;
    padding: 0 2.6%;
    background-color: #ffffff;
    text-align: left;
}

.hello-1 img {
    width: 99%;
    height: 150px;
    border-radius: 10px;
    pointer-events: none;
}

.lastadd {
    position: fixed;
    bottom: 0px;
    background: #37cd87;
    width: 100%;
    height: 50px;
    color: #fff;
    line-height: 50px;
    font-size: 18px;
}

li {
    position: absolute;
}

.cell-Group {
    height: auto;
}
.van-cell--required::before {
    position: absolute;
    left: 0px;
    color: #ee0a24;
    font-size: 14px;
    content: '*';
}
.cell-List {
    display: flex;
    height: 48px;
    line-height: 48px;
    padding-left: 8px;
}
.cell-List-2 {
    display: flex;
    height: 130px;
    line-height: 48px;
    padding-left: 8px;
    color: #969799;
}
.updateImg {
    margin-top: 15px;
    margin-left: 95px;
}
</style>
